<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<script type="text/javascript">


	$(function() {
	
		$('#condidateIds').combotree({
		    url: '${ctx}/voter/tree?usertype=2',
		    multiple: true,
		    required: true,
		    panelHeight : 'auto',
		    value : $.stringToList('${t.candidate}')
		});
		
		$('#voterIds').combotree({
		    url: '${ctx}/voter/tree?usertype=3',
		    multiple: true,
		    required: true,
		    panelHeight : 'auto',
		    value : $.stringToList('${t.voter}')
		});
		
		$('input[type="radio"]').click(function(){
			var c= $(this).is(":checked");
			if(c){
				var v = $(this).val();
				$('#voters').val(v);
			}
		});
		
		window.setInterval("setTimes();",1000);
	});
	
	function setTimes(){
		var time1 = $('#endtime').val();
		var d = new Date();
		 
		$("#clock").html(diy_time(time1,d));
	}
	function addZero(data){
		if(data<10){
			data="0"+data;
		}
		return data;
	}
	
	function diy_time(time1,time2){
	    time1 = Date.parse(new Date(time1));
	    var time = time1 - time2;
	    var days = addZero(parseInt(time / 1000 / 60 / 60 / 24));
	    var hours = addZero(parseInt(time / 1000 / 60 / 60 % 24));
	    var minutes = addZero(parseInt(time / 1000 / 60 % 60));
	    var seconds = addZero(parseInt(time / 1000 % 60));
	    var result = "<span class=\"digit\">" + days + "</span> 天 <span class=\"digit\">" + hours + "</span> 小时 <span class=\"digit\">" + minutes + "</span> 分钟 <span class=\"digit\">" + seconds + "</span> 秒";
	    return result;
	}
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'center',border:false" title="" style="overflow: hidden;padding: 3px;">
		<form id="userAddForm" method="post">
			<c:if test="${t.id != null}">
				<input type="hidden" value="${t.id }" name="id"/>
				<input type="hidden" id="id" value="${vi_id }"/>
				<input type="hidden" id="voters" value=""/>
				<input type="hidden" id="endtime" value="${t.endtime }"/>
			</c:if>
			<table class="grid">
				<tr>
					<td>投票标题</td>
					<td colspan="3">
						${t.title }
					</td>
				</tr>
				<tr height="100px">
					<td>投票内容</td>
					<td colspan="3" valign="top">
						${t.content }
					</td>
				</tr>
				<tr>
					<td colspan="4">距离结束时间还有：
						<font id="clock"></font>
					</td>
				</tr>
				<tr>
					<td>投票类型</td>
					<td colspan="3">
						<c:if test="${t.type=='1'}">一人一票</c:if>
						<c:if test="${t.type=='2'}">一人多票</c:if>
					</td>
				</tr>
				<tr>
					<td>候选人</td>
					<td colspan="3">
						<div style="border: 0px solid #000;width:400px;height: 80px ">
							<c:forEach var="li" items="${lis}">
								${li }
							</c:forEach>
						</div>
					</td>
				</tr>
				
			</table>
		</form>
	</div>
</div>